import 'package:basic_common/toast_utils.dart';
import 'package:basic_widgets/button_widget.dart';
import 'package:basic_widgets/input_widget.dart';
import 'package:basic_widgets/text_widget.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../login_controller.dart';

class SmsLoginView extends GetView<LoginController> {

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        norTitle(title: "手机号"),
        inputBox(
          inputController: controller.phoneNumberController,
          onChanged: (value) {
            if (value.isEmpty || !controller.isRead.value) {
              controller.setBtnEnable(false);
            } else {
              controller.setBtnEnable(true);
            }
          },
        ),
        const SizedBox(
          height: 20,
        ),
        Obx(() => btnComponent(
            onPressed: () {
              if (controller.isRead.value) {
                controller.postLogin();
              } else {
                ToastUtils.toast("请先阅读隐私协议");
                controller.isRead.value = true;
              }
            },
            isEnable: controller.isRead.value,
            textStr: "获取验证码")),
      ],
    );
  }
}
